package com.mingtu.guards.activity;

import android.graphics.Color;
import android.os.Build;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.RequiresApi;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.listener.OnOptionsSelectChangeListener;
import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.ScreenUtils;
import com.blankj.utilcode.util.StringUtils;
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.Legend;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.components.YAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.formatter.ValueFormatter;
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.hjq.gson.factory.GsonFactory;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.mingtu.common.callback.StringDialogCallback;
import com.mingtu.common.utils.Constant;
import com.mingtu.common.utils.MyLogUtil;
import com.mingtu.common.utils.SpacesItemDecoration;
import com.mingtu.common.view.MyAutofitTextView.AutofitTextView;
import com.mingtu.guards.R;
import com.mingtu.guards.adapter.InfrareAnimalDataAdapter;
import com.mingtu.guards.adapter.InfrarePictureAdapter;
import com.mingtu.guards.base.MyBaseActivity;
import com.mingtu.guards.bean.AnimalStatisticsBean;
import com.mingtu.guards.bean.AnimalStatisticsLineBean;
import com.mingtu.guards.bean.DequipmentStaBean;
import com.mingtu.guards.bean.PicMonthStaBean;
import com.mingtu.guards.utils.MyConstant;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.OnClick;

public class InfrareDataAnalysisActivity extends MyBaseActivity {

    @BindView(R.id.tv_pic_num)
    TextView tvPicNum;
    @BindView(R.id.tv_animal_num)
    TextView tvAnimalNum;
    @BindView(R.id.line_chart_pic)
    LineChart lineChartPic;
    @BindView(R.id.recycler_pic)
    RecyclerView recyclerPic;
    @BindView(R.id.tv_valid_num)
    AutofitTextView tvValidNum;
    @BindView(R.id.recycler_animal_num)
    RecyclerView recyclerAnimalNum;
    @BindView(R.id.tv_month_animal_name)
    TextView tvMonthAnimalName;
    @BindView(R.id.line_chart_animal_month)
    LineChart lineChartAnimalMonth;
    @BindView(R.id.tv_hour_animal_name)
    TextView tvHourAnimalName;
    @BindView(R.id.line_chart_animal_hour)
    LineChart lineChartAnimalHour;
    @BindView(R.id.tv_dept_name)
    TextView tvDeptName;
    private InfrarePictureAdapter infrarePictureAdapter;
    private List<DequipmentStaBean.DataBean> DataBeanPic = new ArrayList<>();
    private List<AnimalStatisticsBean.DataBean> DataBeanAnimal = new ArrayList<>();
    private InfrareAnimalDataAdapter infrareAnimalDataAdapter;
    private OptionsPickerView pvOptions;
    private List<String> animalList = new ArrayList<>();
    private List<PicMonthStaBean.ListBean> listBeans;
    private List<AnimalStatisticsLineBean.DataBean> animalMonthDataBean;
    private List<AnimalStatisticsLineBean.DataBean> animalHourDataBean;
    private List<String> deptIdList = new ArrayList<>();
    private List<String> deptNameList = new ArrayList<>();
    private int[] checkArray = {0, 0, 0};

    @Override
    protected int getLayoutId() {
        return R.layout.activity_infrare_data_analysis;
    }

    @Override
    protected void initView() {
        setModuleTitle("数据分析");
    }

    @Override
    protected void initData() {
        LinearLayoutManager manager1 = new LinearLayoutManager(context);
        recyclerPic.setLayoutManager(manager1);
        recyclerPic.addItemDecoration(new SpacesItemDecoration(0, 0, 10, 15, 10));

        infrarePictureAdapter = new InfrarePictureAdapter(context, DataBeanPic);
        recyclerPic.setAdapter(infrarePictureAdapter);

        LinearLayoutManager manager2 = new LinearLayoutManager(context);
        recyclerAnimalNum.setLayoutManager(manager2);
        recyclerAnimalNum.addItemDecoration(new SpacesItemDecoration(0, 0, 15, 0, 10));

        infrareAnimalDataAdapter = new InfrareAnimalDataAdapter(DataBeanAnimal);
        recyclerAnimalNum.setAdapter(infrareAnimalDataAdapter);
    }

    @Override
    protected void getData() {
        getTotalData();
        getMonthSta();
        getAnimalCount();
        getCameraDeptList();
    }

    /**
     * 月拍摄次数趋势
     */
    private void getMonthSta() {
        OkGo.<String>post(MyConstant.POST_INF_MONTH_STA)
                .tag(this)
                .upJson("")
                .execute(new StringDialogCallback(this) {
                    @RequiresApi(api = Build.VERSION_CODES.O)
                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        if (!StringUtils.isEmpty(result)) {
                            Gson gson = GsonFactory.getSingletonGson();
                            PicMonthStaBean picMonthStaBean = new PicMonthStaBean();
                            picMonthStaBean = gson.fromJson(result, PicMonthStaBean.class);
                            List<PicMonthStaBean.ListBean> listBeans = picMonthStaBean.getList();

                            if (listBeans != null) {
                                if (listBeans.size() > 0) {
                                    initLineChartData(listBeans, lineChartPic, 0);
                                }
                            }

                        }
                    }
                });
    }

    public void initLineChartData(Object object, LineChart lineChart, int type) {
        if (type == 0) {
            listBeans = (List<PicMonthStaBean.ListBean>) object;
        }
        if (type == 1) {
            animalMonthDataBean = (List<AnimalStatisticsLineBean.DataBean>) object;
        }
        if (type == 2) {
            animalHourDataBean = (List<AnimalStatisticsLineBean.DataBean>) object;
        }


        int XLabelCount = 5;
        lineChart.getDescription().setEnabled(false);
        lineChart.setDrawGridBackground(false);
        lineChart.setScaleEnabled(false);//不缩放
        lineChart.getAxisRight().setEnabled(false);
        lineChart.setExtraOffsets(0, 00, 0, 0);
//        MyMarkerView myMarkerView = new MyMarkerView(getActivity(), R.layout.layout_chart_marker_view);
//        myMarkerView.setChartView(lineChart);
//        lineChart.setMarker(myMarkerView);

        Legend l = lineChart.getLegend();
        l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
        l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
        l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
        l.setDrawInside(false);
        l.setEnabled(false);

        //相机拍摄照片统计
        if (type == 0) {
            if (listBeans.size() % 2 == 0) {
                XLabelCount = 6;
            }
        }

        //动物出没月统计
        if (type == 1) {
            XLabelCount = animalMonthDataBean.size();
        }

        //动物出没时统计
        if (type == 2) {
            XLabelCount = 12;

        }


        XAxis xAxis = lineChart.getXAxis();
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
        xAxis.setLabelCount(XLabelCount);
        xAxis.setDrawGridLines(true);
        xAxis.setDrawAxisLine(false);
        xAxis.setAxisMinimum(0);
        xAxis.setGranularity(1f);
        xAxis.setGridColor(getResources().getColor(R.color.bg_color_c1c));
        xAxis.setTextColor(getResources().getColor(R.color.text_color999));

        if (type == 0) {
            xAxis.setValueFormatter(new ValueFormatter() {
                @Override
                public String getFormattedValue(float value) {
                    MyLogUtil.e("xxxLinePic", "value=" + value);
                    int MyValue = (int) value;

                    if (value < 0 || MyValue > listBeans.size() - 1) {
                        return "";
                    }
                    String[] data = listBeans.get(MyValue).getRq().split("-");
                    return data[1];
                }
            });
        }


        if (type == 1) {
            xAxis.setValueFormatter(new ValueFormatter() {
                @Override
                public String getFormattedValue(float value) {
                    MyLogUtil.e("xxxLineAnimalMonth", "value=" + value);
                    int MyValue = (int) value;

                    if (value < 0 || MyValue > animalMonthDataBean.size() - 1) {
                        return "";
                    }
                    String data = animalMonthDataBean.get(MyValue).getRq();
                    return data;
                }
            });
        }

        if (type == 2) {
            xAxis.setValueFormatter(new ValueFormatter() {
                @Override
                public String getFormattedValue(float value) {
                    MyLogUtil.e("xxxLineAnimalHour", "value=" + value);
                    int MyValue = (int) value;

                    if (value < 0 || MyValue > animalHourDataBean.size() - 1) {
                        return "";
                    }
                    String data = animalHourDataBean.get(MyValue).getRq();
                    return data;
                }
            });
        }


        List<Integer> numList = new ArrayList<>();
        if (type == 0) {
            for (int i = 0; i < listBeans.size(); i++) {
                int num = listBeans.get(i).getNum();
                numList.add(num);
            }
        }

        if (type == 1) {
            for (int i = 0; i < animalMonthDataBean.size(); i++) {
                int num = animalMonthDataBean.get(i).getNum();
                numList.add(num);
            }
        }

        if (type == 2) {
            for (int i = 0; i < animalHourDataBean.size(); i++) {
                int num = animalHourDataBean.get(i).getNum();
                numList.add(num);
            }
        }


        int YLabelCount = 5;
        if (Collections.max(numList) % 2 == 0) {
            //偶数的时候 设置为6  奇数的时候设置为5
            YLabelCount = 6;
        }

        YAxis leftAxis = lineChart.getAxisLeft();
        leftAxis.setLabelCount(YLabelCount, false);
        leftAxis.setAxisMinimum(0); // this replaces setStartAtZero(true)
        leftAxis.setGranularity(1f);
        leftAxis.setGridColor(getResources().getColor(R.color.bg_color_c1c));
        leftAxis.setTextColor(getResources().getColor(R.color.text_color999));


        YAxis rightAxis = lineChart.getAxisRight();
//        rightAxis.setTypeface(mTf);
        rightAxis.setLabelCount(YLabelCount, false);
        rightAxis.setDrawGridLines(false);
        rightAxis.setAxisMinimum(0); // this replaces setStartAtZero(true)
        rightAxis.setGranularity(1f);
        rightAxis.setGridColor(getResources().getColor(R.color.bg_color_c1c));
        rightAxis.setTextColor(getResources().getColor(R.color.text_color999));


        // set data
        lineChart.setData((LineData) generateDataLine(object, type));

        // do not forget to refresh the chart
        lineChart.invalidate();
        lineChart.animateX(750);

    }

    private LineData generateDataLine(Object object, int type) {

        ArrayList<Entry> e1 = new ArrayList<Entry>();
        if (type == 0) {
            listBeans = (List<PicMonthStaBean.ListBean>) object;
            for (int i = 0; i < listBeans.size(); i++) {
                int num = listBeans.get(i).getNum(); //照片数

                e1.add(new Entry(i, num));

            }
        }
        if (type == 1) {
            animalMonthDataBean = (List<AnimalStatisticsLineBean.DataBean>) object;
            for (int i = 0; i < animalMonthDataBean.size(); i++) {
                int num = animalMonthDataBean.get(i).getNum(); //照片数
                e1.add(new Entry(i, num));
            }
        }
        if (type == 2) {
            animalHourDataBean = (List<AnimalStatisticsLineBean.DataBean>) object;
            for (int i = 0; i < animalHourDataBean.size(); i++) {
                int num = animalHourDataBean.get(i).getNum(); //照片数
                e1.add(new Entry(i, num));
            }
        }


        LineDataSet d1 = new LineDataSet(e1, "New DataSet " + ", (1)");

        d1.setLineWidth(2f);
        d1.setCircleRadius(6f);
        d1.setCircleHoleRadius(3f);
        d1.setDrawCircleHole(true);
        d1.setCircleColor(Color.argb(76, 153, 211, 163));
        d1.setCircleHoleColor(Color.rgb(78, 171, 94));
        d1.setHighLightColor(Color.rgb(153, 211, 163));
        d1.setColor(Color.rgb(153, 211, 163));
        d1.setDrawValues(false);
        d1.setMode(LineDataSet.Mode.CUBIC_BEZIER);


        ArrayList<ILineDataSet> sets = new ArrayList<ILineDataSet>();
        sets.add(d1);
        LineData cd = new LineData(sets);
        return cd;
    }

    /**
     * 获取总数据个数
     */
    private void getTotalData() {
        OkGo.<String>post(MyConstant.POST_INF_ALL_TOTAL)
                .tag(this)
                .upJson("")
                .execute(new StringDialogCallback(this) {
                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        if (!StringUtils.isEmpty(result)) { //{"msg":"success","code":0,"data":{"picCount":1822,"animalCount":16,"validCount":553}}
                            JSONObject jsonObject = JSON.parseObject(result);
                            String msg = jsonObject.getString("msg");
                            if (msg.equals(Constant.RESULT_SUCCESS)) {
                                JSONObject dataObject = jsonObject.getJSONObject("data");
                                if (dataObject != null) {
                                    String num1 = dataObject.getString("picCount");
                                    String num2 = dataObject.getString("animalCount");
                                    String num3 = dataObject.getString("validCount");

                                    if (!StringUtils.isEmpty(num1)) {
                                        tvPicNum.setText(num1 + "");
                                    }
                                    if (!StringUtils.isEmpty(num3)) {
                                        tvValidNum.setText(num3 + "");
                                    }
                                    if (!StringUtils.isEmpty(num2)) {
                                        tvAnimalNum.setText(num2 + "");
                                    }
                                }
                            }
                        }
                    }
                });
    }

    /**
     * 获取各个相机拍摄的个数
     */
    private void getDequipmentData(String deptId) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("deptId", deptId);
        String str = GsonUtils.toJson(hashMap);
        OkGo.<String>post(MyConstant.POST_INF_DEQUI_STA)
                .tag(this)
                .upJson(str)
                .execute(new StringDialogCallback(this) {
                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        if (!StringUtils.isEmpty(result)) {

                            try {
                                Gson gson = GsonFactory.getSingletonGson();
                                DequipmentStaBean dequipmentStaBean = new DequipmentStaBean();
                                dequipmentStaBean = gson.fromJson(result, DequipmentStaBean.class);

                                if (dequipmentStaBean != null) {
                                    List<DequipmentStaBean.DataBean> dataBeans = dequipmentStaBean.getData();
                                    if (dataBeans.size() > 0) {
                                        int totalNum = 0;
                                        for (int i = 0; i < dataBeans.size(); i++) {
                                            DequipmentStaBean.DataBean listBean = dataBeans.get(i);
                                            int num = listBean.getTotal();
                                            totalNum += num;
                                        }
                                        for (int i = 0; i < dataBeans.size(); i++) {
                                            DequipmentStaBean.DataBean listBean = dataBeans.get(i);
                                            int num = listBean.getTotal();
                                            float ratio = num / (float) totalNum; //保留所有小数位
                                            listBean.setRatio(ratio);
                                        }

                                        int screenWidth = ScreenUtils.getScreenWidth();
                                        infrarePictureAdapter.upData(dataBeans, screenWidth);
                                    }
                                }


                            } catch (JsonSyntaxException e) {
                                e.printStackTrace();
                            }
                        }
                    }
                });
    }

    /**
     * 累计发现动物排行
     */
    private void getAnimalCount() {
        OkGo.<String>post(MyConstant.POST_INF_CAMERA_ANIMAL_COUNT)
                .tag(this)
                .upJson("")
                .execute(new StringDialogCallback(this) {
                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        if (!StringUtils.isEmpty(result)) {
                            try {
                                Gson gson = GsonFactory.getSingletonGson();
                                AnimalStatisticsBean animalStatisticsData = new AnimalStatisticsBean();
                                animalStatisticsData = gson.fromJson(result, AnimalStatisticsBean.class);

                                List<AnimalStatisticsBean.DataBean> dataBeans = animalStatisticsData.getData();

                                if (dataBeans != null) {
                                    int size = dataBeans.size();
                                    if (size > 0) {
                                        int totalNum = 0;
                                        for (int i = 0; i < size; i++) {
                                            AnimalStatisticsBean.DataBean dataBean = dataBeans.get(i);
                                            int num = dataBean.getTotal();
                                            String similar = dataBean.getSimilar();
                                            animalList.add(similar);
                                            totalNum += num;
                                        }
                                        for (int i = 0; i < size; i++) {
                                            AnimalStatisticsBean.DataBean dataBean = dataBeans.get(i);
                                            int num = dataBean.getTotal();
                                            float ratio = num / (float) totalNum; //保留所有小数位
                                            dataBean.setRatio(ratio);
                                        }

                                        int screenWidth = ScreenUtils.getScreenWidth();
                                        infrareAnimalDataAdapter.upData(dataBeans, screenWidth);

                                        String animalName = animalList.get(0);
                                        getAnimalMonthAnalysis(animalName);
                                        getAnimalHourAnalysis(animalName);
                                        tvMonthAnimalName.setText(animalName);
                                        tvHourAnimalName.setText(animalName);


                                    }
                                }

                            } catch (JsonSyntaxException e) {
                                e.printStackTrace();
                            }
                        }
                    }
                });
    }

    /**
     * 动物出没月分析
     */
    private void getAnimalMonthAnalysis(String similar) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("similar", similar);
        String str = GsonUtils.toJson(hashMap);
        OkGo.<String>post(MyConstant.POST_INF_CAMERA_ANIMAL_MONTH_ANALYSIS)
                .tag(this)
                .upJson(str)
                .execute(new StringDialogCallback(this) {
                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        if (!StringUtils.isEmpty(result)) {
                            try {
                                Gson gson = GsonFactory.getSingletonGson();
                                AnimalStatisticsLineBean animalStatisticsLineBean = new AnimalStatisticsLineBean();
                                animalStatisticsLineBean = gson.fromJson(result, AnimalStatisticsLineBean.class);
                                List<AnimalStatisticsLineBean.DataBean> dataBeansAnimalMonth = animalStatisticsLineBean.getData();

                                if (dataBeansAnimalMonth != null) {
                                    if (dataBeansAnimalMonth.size() > 0) {
                                        initLineChartData(dataBeansAnimalMonth, lineChartAnimalMonth, 1);
                                    }
                                }
                            } catch (JsonSyntaxException e) {
                                e.printStackTrace();
                            }
                        }
                    }
                });
    }

    /**
     * 动物出没时分析
     */
    private void getAnimalHourAnalysis(String similar) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("similar", similar);
        String str = GsonUtils.toJson(hashMap);
        OkGo.<String>post(MyConstant.POST_INF_CAMERA_ANIMAL_HOUR_ANALYSIS)
                .tag(this)
                .upJson(str)
                .execute(new StringDialogCallback(this) {
                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        if (!StringUtils.isEmpty(result)) {
                            try {
                                Gson gson = GsonFactory.getSingletonGson();
                                AnimalStatisticsLineBean animalStatisticsLineBean = new AnimalStatisticsLineBean();
                                animalStatisticsLineBean = gson.fromJson(result, AnimalStatisticsLineBean.class);

                                List<AnimalStatisticsLineBean.DataBean> dataBeansAnimalHour = animalStatisticsLineBean.getData();

                                if (dataBeansAnimalHour != null) {
                                    if (dataBeansAnimalHour.size() > 0) {
                                        initLineChartData(dataBeansAnimalHour, lineChartAnimalHour, 2);
                                    }
                                }

                            } catch (JsonSyntaxException e) {
                                e.printStackTrace();
                            }
                        }
                    }
                });
    }

    /**
     * 条件选择器
     */

    private void initOptionPicker(int type) {//条件选择器初始化
        pvOptions = new OptionsPickerBuilder(this, new OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int options2, int options3, View v) {
                checkArray[type] = options1;
                if (type == 0) {
                    String animalName = animalList.get(options1);
                    getAnimalMonthAnalysis(animalName);
                    tvMonthAnimalName.setText(animalName);
                } else if (type == 1) {
                    String animalName = animalList.get(options1);
                    getAnimalHourAnalysis(animalName);
                    tvHourAnimalName.setText(animalName);
                } else if (type == 2) {
                    String deptName = deptNameList.get(options1);
                    String deptId = deptIdList.get(options1);
                    getDequipmentData(deptId);
                    tvDeptName.setText(deptName);
                }
            }
        })

                .setContentTextSize(20)//设置滚轮文字大小
                .setDividerColor(Color.LTGRAY)//设置分割线的颜色
                .setSelectOptions(0)//默认选中项
                .setBgColor(Color.WHITE)
                .setTitleBgColor(getResources().getColor(R.color.black_eee))
                .setCancelColor(getResources().getColor(R.color.text_cancel_color))
                .setSubmitColor(getResources().getColor(R.color.text_submit_color))
                .setTextColorCenter(getResources().getColor(R.color.colorPrimary))
                .isRestoreItem(true)//切换时是否还原，设置默认选中第一项。
                .setOutSideColor(getResources().getColor(R.color.translucence)) //设置外部遮罩颜色
                .setOptionsSelectChangeListener(new OnOptionsSelectChangeListener() {
                    @Override
                    public void onOptionsSelectChanged(int options1, int options2, int options3) {

                    }
                })
                .build();

        pvOptions.setSelectOptions(checkArray[type]);
        if (type == 2) {
            pvOptions.setPicker(deptNameList);
        } else {
            pvOptions.setPicker(animalList);

        }
        pvOptions.show();

    }


    @OnClick({R.id.tv_month_animal_name, R.id.tv_hour_animal_name, R.id.tv_dept_name})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_month_animal_name:
                initOptionPicker(0);
                break;
            case R.id.tv_hour_animal_name:
                initOptionPicker(1);
                break;
            case R.id.tv_dept_name:
                initOptionPicker(2);
                break;
        }
    }

    /**
     * 获取部门数据
     */
    private void getCameraDeptList() {
        OkGo.<String>post(MyConstant.POST_INF_DEPT_LIST)
                .tag(this)
                .upJson("")
                .execute(new StringDialogCallback(this) {
                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        if (!StringUtils.isEmpty(result)) {
                            JSONObject jsonObject = JSON.parseObject(result);
                            JSONObject data = jsonObject.getJSONObject("data");
                            for (Map.Entry entry : data.entrySet()) {
                                try {
                                    String key = String.valueOf(entry.getKey());
                                    String value = data.getString(key);
                                    deptIdList.add(key);
                                    deptNameList.add(value);
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }

                            if (deptNameList.size() > 0) {
                                deptIdList.add(null);
                                deptNameList.add("全部");
                                tvDeptName.setVisibility(View.VISIBLE);
                                tvDeptName.setText(deptNameList.get(0));
                                getDequipmentData(deptIdList.get(0));
                            } else {
                                tvDeptName.setVisibility(View.GONE);
                            }
                        }
                    }
                });
    }

}